package es.onlysolutions.gs.web.controller;

import es.onlysolutions.arq.core.mvc.command.AbstractCommandBean;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.validation.BindException;

/**
 * controller to disconnect from the current session and logout
 */
public class LogOutController extends GSController
{

    protected AbstractCommandBean loadPage(HttpServletRequest httpServletRequest) throws Exception
    {
        return null;
    }

    protected ModelAndView onSubmit(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, BindException e) throws Exception
    {
        HttpSession session = httpServletRequest.getSession(false);
        if( session != null )
        {
            session.invalidate();
        }
        return new ModelAndView( getSuccessView() );
    }
}
